package com.zuipin.service;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zuipin.entity.User;
import com.zuipin.mapper.UserMapper;

@Service
public class UserService {
	@Autowired
	private UserMapper userDao;
	
	public String login(User user){
		String password=userDao.selectByusername(user.getUserName());
		if(password==null)
			return "您的用户名不存在，请先注册";
		else if(!password.equals(user.getpassword()))
			return "您的用户名密码不匹配，请重新输入";
		return "登陆成功";
	}
	
	
	
	
	public void testInsert(User user) {
		userDao.save(user);
		System.out.println("插入用户信息" + user.getUserName());
	}
	
	 
    public User testSelect(int id){  
        User user = userDao.selectById(id);  
        System.out.println(user);  
        return user;
    }  
	
	 
    public void testUpdate(User user){  
    	System.out.println(userDao.updateById(user));      
    } 
}
